﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Mewdam.OAuth;
using System.Diagnostics;

namespace Mewdam.Mewdam
{
    public partial class callback : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            MewdamOAuth mo = new MewdamOAuth();
            try
            {
                mo.Parameters.oauth_token = Request.Params["oauth_token"];
                mo.Parameters.oauth_verifier = Request.Params["oauth_verifier"];
                mo.Parameters.oauth_token_secret = Request.Cookies["Authorization"]["oauth_secret"];
            }
            catch (Exception)
            {
                
                //throw;
            }



            if (mo.Parameters.oauth_token==null ||
                mo.Parameters.oauth_token_secret==null)
            {
                Response.Redirect("default.aspx");
            }
            else
            {
                mo.GetAccessToken("ulagogPCgxspCb2bxouyrw",
                    "s24vXeTkPi1WyKXuq3kXJg1FpOIU92x2FQSRfjcs");



                HttpCookie cookie = Request.Cookies["Authorization"];
                cookie["oauth_token"] = mo.Parameters.oauth_token;
                cookie["oauth_secret"] = mo.Parameters.oauth_token_secret;
                cookie["verified"] = "false";

                Response.Cookies["Authorization"].Value  = Request.Cookies["Authorization"].Value;


                Response.Redirect("timeline.aspx");




            }


        }
    }

}